/**
 * 会员中心
 */
var app = getApp()
Page({
	data: {
		root:app.setting.att_url,
		pagedata:[],
		action: '',
		pagetitle:'会员',
		ShowAuthM:false,
		bannerHeight: Math.ceil(290.0 / 750.0 * getApp().screenWidth)
	},
	onReady: function (){
	},
	onShow: function (){
		var ssid=wx.getStorageSync('ssid');
		if(!ssid && !app.issession){
			app.util.session();
		}
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (options){
		var the = this;
		wx.setNavigationBarTitle({'title':the.data.pagetitle});
		the.getpagedata();
	},
	getpagedata: function (){
		var the=this;
		var pagedata= the.data.pagedata
		app.util.get(app.access,function(res){
			the.setData({
				pagedata:res,
				ShowAuthM:pagedata.show_setmember==2?true:false,
				pluginnav:app.session.menus,
				action:app.access.plugin+'/'+app.access.action+'/',
			});
		});
	},
	onChooseAvatar:function(e){
		//获取头像
		var the=this;
		var avatarUrl= e.detail.avatarUrl
		the.setData({
			avatarUrl:avatarUrl
		})
		app.avatarUrl=avatarUrl
	},
	info_login:function(e){
		//根据openid为用户登陆，此处尝试获取用户信息
		var the=this;
		app.util.getUserInfo(e,function(res){
			if(res && res.userInfo){
				app.isgetUserInfo=true
				the.setData({
					ShowAuthM:false
				})
				the.onLoad();
			}else{
				return false;
			}
		});
	},
	mobile_login:function(e){
		//根据openid为用户登陆，此处尝试获取用户手机号
		var the = this
		var pagedata= the.data.pagedata
		app.util.post('core/member.login/wxapp_login/return_mobile=1',e.detail,function(res){
			the.setData({
				ShowAuthM:false
			})
		});
	},
	closeAuthM:function(){
		var the=this;
		the.setData({
			ShowAuthM:false,
		})
	},
	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		//console.log(evt);
		app.util[data.func](data.params);
	}
})